package com.example.smartf;

import com.example.smartf.model.mysql.Deviceinfo;
import com.example.smartf.model.mysql.Traindata;
import com.example.smartf.model.mysql.Userinfo;
import com.example.smartf.repository.mysql.DeviceinfoRepository;
import com.example.smartf.repository.mysql.TraindataRepository;
import com.example.smartf.repository.mysql.UserinfoRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Iterator;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class jpatest {
    @Autowired
    UserinfoRepository userinfoRepository;
    @Autowired
    DeviceinfoRepository deviceinfoRepository;
    @Autowired
    TraindataRepository traindataRepository;



    @Test
    public void jpaatest() throws Exception{
//        System.out.println(userinfoRepository.findByUsername("1033457564@qq.com"));
//        System.out.println(deviceinfoRepository.findByDeviceid("6af6188e14aa"));
//
//        userinfoRepository.save(new Userinfo("ypq@163.com","aaa"));
//        deviceinfoRepository.save(new Deviceinfo("1233333","2019-9-6",12.666,445.542));
//
//        System.out.println(deviceinfoRepository.findByDeviceid("1233333"));
//        List<Traindata> list = traindataRepository.findAllByTraindataKeyDeviceIDOrderByTraindataKey_Days("6af6188e14aa");
//        Iterator<Traindata> iterator = list.iterator();
//        while (iterator.hasNext()){
//            System.out.println(iterator.next());
//        }
//        System.out.println(traindataRepository.findByTraindataKey_DaysAndTraindataKey_DeviceID(1,"6af6188e14aa"));
        //traindataRepository.updateCgr("6af6188e14aa",3,2.33);
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("aaaa"+"\n");
        stringBuilder.append("bbbb" + "\n");
        System.out.println(stringBuilder.toString());
    }
}
